<?php
namespace Admin\Controller;
use Common\Controller\AdminBaseController;

class AdminController extends AdminBaseController  {

    // 我的资料
    public function my($id=UID){
        if(IS_POST){$this->editPost($id);exit;}

        $info = M('Admin')->find($id);
        $this->assign('info',$info);
        $this->display();
    }

    // 处理我的资料
    private function editPost($id){
        $Model=D('Admin');
        $data=$Model->create();
        if(!$data) $this->error($Model->getError());
        $return = $Model->save($data);
        if($return === 0 ){
            $this->success('您没修改过任何一项。');
        }elseif($return == 1){
            $this->success('修改成功');
        }else {
            $this->error('修改失败');
        }
    }


    private function addPost(){
        $Model = D('Admin');
        $data=$Model->create();
        if(!$data) $this->error($Model->getError());

        $return=$Model->add($data);
        if($return) $this->success('添加成功');
        else $this->error('添加失败');
    }



}